gtk/textview: Do not forcibly show text handles
authorCarlos Garnacho <carlosg@gnome.org>
Thu, 5 Nov 2020 20:15:47 +0000 (21:15 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Thu, 5 Nov 2020 20:29:20 +0000 (21:29 +0100)
The gtk_text_view_set_handle_position() function called some lines above
takes care of handle visibility already, also accounting for other
conditions (e.g. whether the handle points to contents onscreen).
Forcibly showing handles here misbehaves if the handle should stay hidden,
and somewhat expensively as it involves creating and throwing a native
surface every time.

gtk/gtktextview.c

index 152238e2e26452cf3b36c294f7656d4af37a89a5..dec6ec64dac2fe8d158cf79c44a1dd239218a598 100644 (file)
@@ -5217,7 +5217,6 @@ gtk_text_view_update_handles (GtkTextView *text_view)
                                              &cursor);
           gtk_text_handle_set_role (priv->text_handles[TEXT_HANDLE_CURSOR],
                                     GTK_TEXT_HANDLE_ROLE_CURSOR);
-          gtk_widget_show (GTK_WIDGET (priv->text_handles[TEXT_HANDLE_CURSOR]));
         }
       else if (gtk_text_iter_compare (&cursor, &bound) != 0)
         {
@@ -5227,14 +5226,12 @@ gtk_text_view_update_handles (GtkTextView *text_view)
                                              &cursor);
           gtk_text_handle_set_role (priv->text_handles[TEXT_HANDLE_CURSOR],
                                     GTK_TEXT_HANDLE_ROLE_SELECTION_START);
-          gtk_widget_show (GTK_WIDGET (priv->text_handles[TEXT_HANDLE_CURSOR]));
 
           gtk_text_view_set_handle_position (text_view,
                                              priv->text_handles[TEXT_HANDLE_SELECTION_BOUND],
                                              &bound);
           gtk_text_handle_set_role (priv->text_handles[TEXT_HANDLE_SELECTION_BOUND],
                                     GTK_TEXT_HANDLE_ROLE_SELECTION_END);
-          gtk_widget_show (GTK_WIDGET (priv->text_handles[TEXT_HANDLE_SELECTION_BOUND]));
         }
       else
         {